package source;

import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.swing.Box;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

import activejdbc.Base;
import activejdbc.Model;



public class Window extends JFrame {
	/**
	 * 
	 */
	
 	private Model loggedUser;
	private char loggedUserType;
	
	private static final long serialVersionUID = -3818121213029378847L;
	private JTextField txtField_Username;
	private JTextField txtField_Password;
	private JTextField txtTreatingDoctor;
	private JTextField txtTreatmentDate;
	private JTextField txtSymptoms;
	private JTextField txtTime;
	private JTextField txtNurse;
	private JTextField txtDiagnosis;
	private JTextField txtName;
	private JTextField txtReason;
	private JTextField txtDesiredDate;
	private JTextField txtFName;
	private JTextField txtAge;
	private JTextField txtAddress;
	private JTextField txtPhoneAreaCode;
	private JTextField txtEmail;
	private JTextField txtPharmacy;
	private JTextField txtInsuranceCarrier;
	private JTextField txtAllergies;
	private JTextField txtTemperature;
	private JTextField txtPulse;
	private JTextField txtBloodPressure;
	private JTextField txtHeight;
	private JTextField txtWeight;
	private JTextField txtUserFullName;
	private JTextField txtUserAge;
	private JTextField txtUserAddress;
	private JTextField txtUserPhone;
	private JTextField txtUserEmail;
	private JTextField txtUserPharmacy;
	private JTextField txtUserInsuranceCarrier;
	private JTextField txtUserAllergies;
	private JTable tblInvoice;
	private JLabel lblNurse_AddPatient;
	
	// functioning variables
	private boolean loggedIn = false;
	private JTextField txtDate;
	private JTextField txtPhonePrefix;
	private JTextField txtPhone4;
	private JTextField txtOrderPatientName;
	private JTextField txtOrderNotes;
	private JTextField txtOrderDate;
	private JButton btnMenuLogout;
	private JRadioButtonMenuItem rdbtnID;
	private JRadioButtonMenuItem rdbtnUsername;
	private JRadioButtonMenuItem rdbtnFN;
	
	// JPanels
	private JPanel newUserPanel;
	private JPanel newApptPanel;
	private JPanel docOrdersPanel;
	private JPanel userInfo;
	private JPanel newTreatmentPanel;
	private JPanel invoicePanel;
	private JPanel docPanel;
	private JPanel adminPanel;
	private JPanel nursePanel;
	private JPanel patientPanel;
	private JPanel chartPanel;
	private JPanel loginPanel;
	private JPanel searchPanel;
	private JPanel historyPanel;
	private JPanel apptsPanel;
	private JTextField txtSearch_Query;
	private JTable table;
	private JMenuBar menu;
	private JTable table_Appointments;
	private JTextField txtUsername;
	
	public enum userType{Patient, Nurse, Admin, Doctor}
	public Window() {
		
		/* test drawChart */
		//drawChart();
		
		//Set so that exit button on top left closes application
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLocationRelativeTo(null);
		
		getLayeredPane().setLayout(null);
		
		JLayeredPane layeredPane = new JLayeredPane();
		layeredPane.setBounds(0, 0, 540, 580);
		getLayeredPane().add(layeredPane);
		
		newUserPanel = new JPanel();
		newUserPanel.setLayout(null);
		newUserPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(newUserPanel);
		
		txtFName = new JTextField();
		txtFName.setColumns(10);
		txtFName.setBounds(194, 135, 183, 20);
		newUserPanel.add(txtFName);
		
		JLabel lblFullName = new JLabel("Full Name:");
		lblFullName.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFullName.setBounds(120, 138, 64, 14);
		newUserPanel.add(lblFullName);
		
		JLabel lblUserType = new JLabel("User Type:");
		lblUserType.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblUserType.setBounds(25, 91, 74, 20);
		newUserPanel.add(lblUserType);
		
		JLabel lblPersonal = new JLabel("Personal:");
		lblPersonal.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblPersonal.setBounds(35, 135, 87, 14);
		newUserPanel.add(lblPersonal);
		
		JLabel lblMedical = new JLabel("Medical:");
		lblMedical.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblMedical.setBounds(35, 324, 64, 14);
		newUserPanel.add(lblMedical);
		
		txtAge = new JTextField();
		txtAge.setColumns(10);
		txtAge.setBounds(194, 208, 39, 20);
		newUserPanel.add(txtAge);
		
		JLabel lblAge = new JLabel("Age:");
		lblAge.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAge.setBounds(120, 211, 64, 14);
		newUserPanel.add(lblAge);
		
		JLabel lblAddress = new JLabel("Address:");
		lblAddress.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAddress.setBounds(120, 160, 64, 14);
		newUserPanel.add(lblAddress);
		
		txtAddress = new JTextField();
		txtAddress.setFont(new Font("Tahoma", Font.PLAIN, 11));
		
		//NEWUSERPANEL - erase default entries in Address Field when selected with "tab"
		txtAddress.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				txtAddress.setText(null);
			}
		});
		
		//NEWUSERPANEL - erase default entries in Address Field when mouse clicked
		txtAddress.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				txtAddress.setText(null);
			}
		});
		txtAddress.setText("(# street, city, state, zip)");
		txtAddress.setHorizontalAlignment(SwingConstants.CENTER);
		txtAddress.setColumns(10);
		txtAddress.setBounds(194, 157, 183, 49);
		newUserPanel.add(txtAddress);
		
		txtPhoneAreaCode = new JTextField();
		txtPhoneAreaCode.setHorizontalAlignment(SwingConstants.CENTER);
		txtPhoneAreaCode.setColumns(10);
		txtPhoneAreaCode.setBounds(194, 254, 39, 20);
		newUserPanel.add(txtPhoneAreaCode);
		
		JLabel lblPhone = new JLabel("Phone:");
		lblPhone.setHorizontalAlignment(SwingConstants.RIGHT);
		lblPhone.setBounds(120, 257, 64, 14);
		newUserPanel.add(lblPhone);
		
		JLabel lblEmail = new JLabel("E-mail:");
		lblEmail.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEmail.setBounds(120, 279, 64, 14);
		newUserPanel.add(lblEmail);
		
		txtEmail = new JTextField();
		txtEmail.setColumns(10);
		txtEmail.setBounds(194, 276, 183, 20);
		newUserPanel.add(txtEmail);
		
		JLabel lblPharmacy = new JLabel("Pharmacy:");
		lblPharmacy.setHorizontalAlignment(SwingConstants.RIGHT);
		lblPharmacy.setBounds(120, 326, 64, 14);
		newUserPanel.add(lblPharmacy);
		
		JLabel lblInsuranceCarrier = new JLabel("Insurance Carrier:");
		lblInsuranceCarrier.setHorizontalAlignment(SwingConstants.RIGHT);
		lblInsuranceCarrier.setBounds(66, 349, 118, 14);
		newUserPanel.add(lblInsuranceCarrier);
		
		txtPharmacy = new JTextField();
		txtPharmacy.setColumns(10);
		txtPharmacy.setBounds(194, 323, 183, 20);
		newUserPanel.add(txtPharmacy);
		
		txtInsuranceCarrier = new JTextField();
		txtInsuranceCarrier.setColumns(10);
		txtInsuranceCarrier.setBounds(194, 345, 183, 20);
		newUserPanel.add(txtInsuranceCarrier);
		
		JLabel lblAllergies = new JLabel("Allergies:");
		lblAllergies.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAllergies.setBounds(120, 370, 64, 14);
		newUserPanel.add(lblAllergies);
		
		txtAllergies = new JTextField();
		txtAllergies.setColumns(10);
		txtAllergies.setBounds(194, 367, 183, 47);
		newUserPanel.add(txtAllergies);
		
		final JComboBox dropDnUserType = new JComboBox();//made final for event handling, subject to change
		dropDnUserType.setModel(new DefaultComboBoxModel(new String[] {"Patient", "Nurse", "Doctor", "Admin"}));
		dropDnUserType.setBounds(194, 93, 106, 20);
		newUserPanel.add(dropDnUserType);
		
		JLabel gfxAddUser = new JLabel("");
		gfxAddUser.setIcon(new ImageIcon(Window.class.getResource("/gfx/add_user_128.png")));
		gfxAddUser.setBounds(378, 27, 162, 128);
		newUserPanel.add(gfxAddUser);
		
		JLabel lblAddANew = new JLabel("[ Add A New User ]");
		lblAddANew.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblAddANew.setBounds(10, 11, 377, 83);
		newUserPanel.add(lblAddANew);
		
		JLabel gfxHospital = new JLabel("");
		gfxHospital.setIcon(new ImageIcon(Window.class.getResource("/gfx/Hospital-128.png")));
		gfxHospital.setHorizontalAlignment(SwingConstants.CENTER);
		gfxHospital.setBounds(378, 217, 162, 144);
		newUserPanel.add(gfxHospital);
		
		JLabel btnNewUser_Clear = new JLabel("");
		btnNewUser_Clear.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				txtFName.setText(null);
				txtAddress.setText(null);
				txtAge.setText(null);
				txtDate.setText(null);
				txtPhoneAreaCode.setText(null);
				txtPhonePrefix.setText(null);
				txtPhone4.setText(null);
				txtEmail.setText(null);
				txtPharmacy.setText(null);
				txtInsuranceCarrier.setText(null);
				txtAllergies.setText(null);
			}
		});
		
		
		JLabel lblDob = new JLabel("DOB:");
		lblDob.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDob.setBounds(120, 234, 64, 14);
		newUserPanel.add(lblDob);
		
		txtDate = new JTextField();
		txtDate.setColumns(10);
		txtDate.setBounds(284, 231, 39, 20);
		newUserPanel.add(txtDate);
		
		final JComboBox comboBox_1 = new JComboBox();
		comboBox_1.setFont(new Font("Tahoma", Font.PLAIN, 9));
		//comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}));
		comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"1","2","3","4","5","6","7","8","9","10","11","12"}));
		comboBox_1.setBounds(194, 231, 87, 20);
		newUserPanel.add(comboBox_1);
		
		final JComboBox comboBox_2 = new JComboBox();
		comboBox_2.setFont(new Font("Tahoma", Font.PLAIN, 9));
		comboBox_2.setModel(new DefaultComboBoxModel(new String[] {"2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", "1943", "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932", "1931", "1930", "1929", "1928", "1927", "1926", "1925", "1924", "1923", "1922", "1921", "1920"}));
		comboBox_2.setBounds(329, 231, 48, 20);
		newUserPanel.add(comboBox_2);
		
		JLabel lblNewLabel_1 = new JLabel("-");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setBounds(227, 257, 19, 14);
		newUserPanel.add(lblNewLabel_1);
		
		txtPhonePrefix = new JTextField();
		txtPhonePrefix.setHorizontalAlignment(SwingConstants.CENTER);
		txtPhonePrefix.setColumns(10);
		txtPhonePrefix.setBounds(239, 254, 39, 20);
		newUserPanel.add(txtPhonePrefix);
		
		txtPhone4 = new JTextField();
		txtPhone4.setHorizontalAlignment(SwingConstants.CENTER);
		txtPhone4.setColumns(10);
		txtPhone4.setBounds(284, 254, 39, 20);
		newUserPanel.add(txtPhone4);
		
		JLabel label = new JLabel("-");
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setBounds(272, 257, 19, 14);
		newUserPanel.add(label);
		
		JLabel lblNewLabel_2 = new JLabel("years");
		lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNewLabel_2.setBounds(238, 211, 39, 14);
		newUserPanel.add(lblNewLabel_2);
		
		btnNewUser_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnNewUser_Clear.setBounds(215, 458, 50, 25);
		newUserPanel.add(btnNewUser_Clear);
		
		JButton btnNewUser_Submit = new JButton("");
		btnNewUser_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				Map<String, String> addUserSubmit=new HashMap<String, String>();
			
				addUserSubmit.put("username", txtUsername.getText());
				addUserSubmit.put("password", txtAge.getText());
				addUserSubmit.put("name", txtFName.getText());
				
				switch(userType.valueOf((String)dropDnUserType.getSelectedItem())){
					case Patient:
						addUserSubmit.put("pharmacy", txtPharmacy.getText());
						addUserSubmit.put("insurance", txtInsuranceCarrier.getText());
						addUserSubmit.put("allergies", txtAllergies.getText());
						addUserSubmit.put("address", txtAddress.getText());
						addUserSubmit.put("date_of_birth", (new Date(Integer.parseInt((String)comboBox_2.getSelectedItem()),Integer.parseInt((String)comboBox_1.getSelectedItem()),Integer.parseInt(txtDate.getText()))).toString());
						addUserSubmit.put("phone", txtPhoneAreaCode.getText() + txtPhonePrefix.getText() + txtPhone4.getText());
						addUserSubmit.put("gender", txtAge.getText());
						addUserSubmit.put("pharmacy", txtAge.getText());
						addUserSubmit.put("insurance", txtAge.getText());
						addUserSubmit.put("email", txtEmail.getText());
						Patient p = new Patient();
						p.fromMap(addUserSubmit);
						p.saveIt();
						break;
					case Doctor:
						if(loggedUserType == 'a') {	
							Doctor d = new Doctor();
							d.fromMap(addUserSubmit);
							d.saveIt();
						}
						break;
					case Nurse:
						if(loggedUserType == 'a') {	
							Nurse n = new Nurse();
							n.fromMap(addUserSubmit);
							n.saveIt();
						}
						break;
					case Admin:
						if(loggedUserType == 'a') {	
							SystemAdministrator s = new SystemAdministrator();
							s.fromMap(addUserSubmit);
							s.saveIt();
						}
						break;	
				}
				/*FIND*/
				hideAll();
				switch(loggedUserType) {
				case 'a':
					adminPanel.setVisible(true);
					break;
				case 'p':
					patientPanel.setVisible(true);
					break;
				case 'n':
					nursePanel.setVisible(true);
					break;
				case 'd':
					docPanel.setVisible(true);
					break;
			}
				//User.addUser(addUserSubmit);
			}
		});
		btnNewUser_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnNewUser_Submit.setBounds(313, 458, 50, 25);
		newUserPanel.add(btnNewUser_Submit);
		
		JLabel lblUsername = new JLabel("Username:");
		lblUsername.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblUsername.setBounds(110, 425, 74, 20);
		newUserPanel.add(lblUsername);
		
		txtUsername = new JTextField();
		txtUsername.setColumns(10);
		txtUsername.setBounds(194, 427, 183, 20);
		newUserPanel.add(txtUsername);
		
		docPanel = new JPanel();
		docPanel.setLayout(null);
		docPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(docPanel);
		
		JLabel btnDoc_Search = new JLabel("");
		btnDoc_Search.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				searchPanel.setVisible(true);
			}
		});
		btnDoc_Search.setIcon(new ImageIcon(Window.class.getResource("/gfx/Search-database-48.png")));
		btnDoc_Search.setToolTipText("");
		btnDoc_Search.setHorizontalAlignment(SwingConstants.CENTER);
		btnDoc_Search.setBounds(270, 186, 80, 80);
		docPanel.add(btnDoc_Search);
		
		JLabel gfxDoctor = new JLabel("");
		gfxDoctor.setIcon(new ImageIcon(Window.class.getResource("/gfx/Doctor-128.png")));
		gfxDoctor.setBounds(402, 28, 128, 128);
		docPanel.add(gfxDoctor);
		
		JLabel lblDoc_AddPatient = new JLabel("Add User");
		lblDoc_AddPatient.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_AddPatient.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_AddPatient.setBounds(90, 265, 80, 14);
		docPanel.add(lblDoc_AddPatient);
		
		JLabel lblDoctorPanel = new JLabel("[ Doctor Panel ]");
		lblDoctorPanel.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblDoctorPanel.setBounds(10, 11, 358, 63);
		docPanel.add(lblDoctorPanel);
		
		JButton btnDoc_NewPatient = new JButton("");
		btnDoc_NewPatient.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				newUserPanel.setVisible(true);
			}
		});
		btnDoc_NewPatient.setIcon(new ImageIcon(Window.class.getResource("/gfx/User-add-48.png")));
		btnDoc_NewPatient.setBounds(90, 186, 80, 80);
		docPanel.add(btnDoc_NewPatient);
		
		JButton btnDoc_NewTreatmentRecord = new JButton("");
		btnDoc_NewTreatmentRecord.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				newTreatmentPanel.setVisible(true);	
			}
		});
		btnDoc_NewTreatmentRecord.setIcon(new ImageIcon(Window.class.getResource("/gfx/Report-48.png")));
		btnDoc_NewTreatmentRecord.setBounds(180, 186, 80, 80);
		docPanel.add(btnDoc_NewTreatmentRecord);
		
		JButton button = new JButton("");
		button.setBounds(270, 186, 80, 80);
		docPanel.add(button);
		
		JButton btnDoc_ViewAppointments = new JButton("");
		btnDoc_ViewAppointments.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				/* needs to be viewAppointmentsPanel */
				apptsPanel.setVisible(true);
			}
		});
		btnDoc_ViewAppointments.setIcon(new ImageIcon(Window.class.getResource("/gfx/Calendar-48.png")));
		btnDoc_ViewAppointments.setBounds(360, 186, 80, 80);
		docPanel.add(btnDoc_ViewAppointments);
		
		JButton btnDoc_AddOrders = new JButton("");
		btnDoc_AddOrders.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
			hideAll();
			docOrdersPanel.setVisible(true);
			}
		});
		btnDoc_AddOrders.setIcon(new ImageIcon(Window.class.getResource("/gfx/case-48x48.png")));
		btnDoc_AddOrders.setBounds(135, 290, 80, 80);
		docPanel.add(btnDoc_AddOrders);
		
		JButton btnDoc_Reports = new JButton("");
		btnDoc_Reports.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				chartPanel.setVisible(true);
			}
		});
		btnDoc_Reports.setIcon(new ImageIcon(Window.class.getResource("/gfx/Chart-1-64.png")));
		btnDoc_Reports.setBounds(315, 290, 80, 80);
		docPanel.add(btnDoc_Reports);
		
		JLabel lblDoc_NewTreatmentRecord = new JLabel("Treatment Records");
		lblDoc_NewTreatmentRecord.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_NewTreatmentRecord.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_NewTreatmentRecord.setBounds(180, 265, 80, 14);
		docPanel.add(lblDoc_NewTreatmentRecord);
		
		JLabel lblDoc_LookUpPatient = new JLabel("Search Users");
		lblDoc_LookUpPatient.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_LookUpPatient.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_LookUpPatient.setBounds(270, 265, 80, 14);
		docPanel.add(lblDoc_LookUpPatient);
		
		JLabel lblDoc_Appointments = new JLabel("Appointments");
		lblDoc_Appointments.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_Appointments.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_Appointments.setBounds(360, 265, 80, 14);
		docPanel.add(lblDoc_Appointments);
		
		JLabel lblDoc_AddOrders = new JLabel("Add Orders");
		lblDoc_AddOrders.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_AddOrders.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_AddOrders.setBounds(135, 370, 80, 14);
		docPanel.add(lblDoc_AddOrders);
		
		JLabel lblDoc_ViewReports = new JLabel("View Reports");
		lblDoc_ViewReports.setHorizontalAlignment(SwingConstants.CENTER);
		lblDoc_ViewReports.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblDoc_ViewReports.setBounds(315, 370, 80, 14);
		docPanel.add(lblDoc_ViewReports);
		
		userInfo = new JPanel();
		userInfo.setLayout(null);
		userInfo.setBounds(0, 25, 540, 583);
		layeredPane.add(userInfo);
		
		txtUserFullName = new JTextField();
		txtUserFullName.setColumns(10);
		txtUserFullName.setBounds(194, 144, 183, 20);
		//System.out.println(loggedUser.getString("name"));
		
		if (loggedUser != null) txtUserFullName.setText(loggedUser.getString("name"));
		
		userInfo.add(txtUserFullName);
		
		JLabel lblUserFullName = new JLabel("Name:");
		lblUserFullName.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserFullName.setBounds(120, 147, 64, 14);
		userInfo.add(lblUserFullName);
		
		JLabel label_13 = new JLabel("User Type:");
		label_13.setFont(new Font("Tahoma", Font.BOLD, 14));
		label_13.setBounds(23, 108, 76, 20);
		userInfo.add(label_13);
		
		JLabel label_22 = new JLabel("Personal:");
		label_22.setFont(new Font("Tahoma", Font.BOLD, 14));
		label_22.setBounds(35, 144, 226, 14);
		userInfo.add(label_22);
		
		JLabel label_25 = new JLabel("Medical:");
		label_25.setFont(new Font("Tahoma", Font.BOLD, 14));
		label_25.setBounds(35, 301, 64, 14);
		userInfo.add(label_25);
		
		txtUserAge = new JTextField();
		txtUserAge.setColumns(10);
		txtUserAge.setBounds(194, 217, 39, 20);
		txtUserAge.setText("testAge");
		userInfo.add(txtUserAge);
		
		JLabel lblUserAge = new JLabel("Age:");
		lblUserAge.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserAge.setBounds(120, 220, 64, 14);
		userInfo.add(lblUserAge);
		
		JLabel lblUserAddress = new JLabel("Address:");
		lblUserAddress.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserAddress.setBounds(120, 169, 64, 14);
		userInfo.add(lblUserAddress);
		
		txtUserAddress = new JTextField();
		txtUserAddress.setText("(# street, city, state, zip)");
		txtUserAddress.setHorizontalAlignment(SwingConstants.CENTER);
		txtUserAddress.setColumns(10);
		txtUserAddress.setBounds(194, 166, 183, 49);
		txtUserAddress.setText("Test-Georgia Tech, Atlanta, GA");
		userInfo.add(txtUserAddress);
		
		txtUserPhone = new JTextField();
		txtUserPhone.setColumns(10);
		txtUserPhone.setBounds(194, 239, 183, 20);
		txtUserPhone.setText("test-000-0000");
		userInfo.add(txtUserPhone);
		
		JLabel lblUserPhone = new JLabel("Phone:");
		lblUserPhone.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserPhone.setBounds(120, 242, 64, 14);
		userInfo.add(lblUserPhone);
		
		JLabel lblUserEmail = new JLabel("E-mail:");
		lblUserEmail.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserEmail.setBounds(120, 266, 64, 14);
		userInfo.add(lblUserEmail);
		
		txtUserEmail = new JTextField();
		txtUserEmail.setColumns(10);
		txtUserEmail.setBounds(194, 263, 183, 20);
		txtUserEmail.setText("aaaaaaa@aaaa.aaa");
		userInfo.add(txtUserEmail);
		
		JLabel lblUserPharmacy = new JLabel("Pharmacy:");
		lblUserPharmacy.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserPharmacy.setBounds(120, 303, 64, 14);
		userInfo.add(lblUserPharmacy);
		
		JLabel lblUserInsurance = new JLabel("Insurance Carrier:");
		lblUserInsurance.setHorizontalAlignment(SwingConstants.RIGHT);
		lblUserInsurance.setBounds(67, 328, 118, 14);
		userInfo.add(lblUserInsurance);
		
		txtUserPharmacy = new JTextField();
		txtUserPharmacy.setColumns(10);
		txtUserPharmacy.setBounds(194, 300, 183, 20);
		txtUserPharmacy.setText("test-pharmacy");
		userInfo.add(txtUserPharmacy);
		
		txtUserInsuranceCarrier = new JTextField();
		txtUserInsuranceCarrier.setColumns(10);
		txtUserInsuranceCarrier.setBounds(194, 325, 183, 20);
		txtUserInsuranceCarrier.setText("test-Insurance");
		userInfo.add(txtUserInsuranceCarrier);
		
		JLabel label_32 = new JLabel("Allergies:");
		label_32.setHorizontalAlignment(SwingConstants.RIGHT);
		label_32.setBounds(120, 353, 64, 14);
		userInfo.add(label_32);
		
		txtUserAllergies = new JTextField();
		txtUserAllergies.setColumns(10);
		txtUserAllergies.setBounds(194, 350, 183, 20);
		txtUserAllergies.setText("test-Allergies");
		userInfo.add(txtUserAllergies);
		
		JLabel gfxFile = new JLabel("");
		gfxFile.setIcon(new ImageIcon(Window.class.getResource("/gfx/Report-128.png")));
		gfxFile.setHorizontalAlignment(SwingConstants.CENTER);
		gfxFile.setBounds(400, 183, 118, 144);
		userInfo.add(gfxFile);
		
		JLabel lblDisplayUserType = new JLabel("(display user type)");
		lblDisplayUserType.setBounds(194, 113, 183, 20);
		userInfo.add(lblDisplayUserType);
		
		JLabel gfxUserspic = new JLabel("");
		gfxUserspic.setIcon(new ImageIcon(Window.class.getResource("/gfx/User-group-128.png")));
		gfxUserspic.setBounds(402, 25, 128, 128);
		userInfo.add(gfxUserspic);
		
		JCheckBox chckbxAccountIsActive = new JCheckBox("Account is active");
		chckbxAccountIsActive.setSelected(true);
		chckbxAccountIsActive.setBounds(194, 377, 107, 23);
		userInfo.add(chckbxAccountIsActive);
		
		JLabel lblPersonalInformation = new JLabel("[ User Information ]");
		lblPersonalInformation.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblPersonalInformation.setBounds(9, 15, 311, 49);
		userInfo.add(lblPersonalInformation);
		
		JButton btnDeleteAccount = new JButton("Delete Account");
		btnDeleteAccount.setBounds(205, 422, 128, 23);
		userInfo.add(btnDeleteAccount);
		
		JLabel lblUser_Administration = new JLabel("Admin:");
		lblUser_Administration.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblUser_Administration.setBounds(120, 424, 64, 14);
		userInfo.add(lblUser_Administration);
		
		JButton btnChangePassword = new JButton("Change Password");
		btnChangePassword.setBounds(205, 447, 128, 23);
		userInfo.add(btnChangePassword);
		
		historyPanel = new JPanel();
		historyPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(historyPanel);
		historyPanel.setLayout(null);
		
		JLabel lblTreatment_History = new JLabel("[ Treatment History ]");
		lblTreatment_History.setBounds(10, 11, 307, 39);
		lblTreatment_History.setFont(new Font("Tahoma", Font.PLAIN, 32));
		historyPanel.add(lblTreatment_History);
		
		table = new JTable();
		
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{"sleepiness, tiredness", "4/29/2011"},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
			},
			new String[] {
				"Symptoms", "Date"
			}
		));
		table.setValueAt("TTT", 0, 1);
		table.setValueAt("TEST2",8 ,0);
		
		
		table.getColumnModel().getColumn(0).setPreferredWidth(343);
		table.setBounds(10, 82, 520, 325);
		historyPanel.add(table);
		
		JLabel lblHistory_Symptoms = new JLabel("Symptoms");
		lblHistory_Symptoms.setHorizontalAlignment(SwingConstants.LEFT);
		lblHistory_Symptoms.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblHistory_Symptoms.setBounds(59, 67, 67, 14);
		historyPanel.add(lblHistory_Symptoms);
		
		JLabel lblHistory_Date = new JLabel("Date");
		lblHistory_Date.setHorizontalAlignment(SwingConstants.LEFT);
		lblHistory_Date.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblHistory_Date.setBounds(402, 67, 67, 14);
		historyPanel.add(lblHistory_Date);
		
		JLabel lblClickOnA = new JLabel("click on a cell to show details");
		lblClickOnA.setBounds(180, 418, 155, 14);
		historyPanel.add(lblClickOnA);
		
		JButton btnViewReportChart = new JButton("View Health History");
		btnViewReportChart.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				if(loggedUserType == 'p') {
					DefaultCategoryDataset d = new DefaultCategoryDataset();
					List<TreatmentRecord> tr = loggedUser.getAll(TreatmentRecord.class);
					List<Vital> vt = null;
					Iterator<TreatmentRecord> i = tr.iterator();
					TreatmentRecord t = null;
					while(i.hasNext()) {
						t = i.next();
						vt = t.getAll(Vital.class);
						if(vt.size() == 1) {
							d.addValue((Number)(vt.get(0)).get("weight"), "Weight", (Date)t.get("date"));
						}
					}
					Window.drawChart(d);
				}
			}
		});
		btnViewReportChart.setBounds(20, 465, 148, 29);
		historyPanel.add(btnViewReportChart);
		
		/* put values into treatmentRecords history table */
		
		apptsPanel = new JPanel();
		apptsPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(apptsPanel);
		apptsPanel.setLayout(null);
		
		JLabel lblAppointments = new JLabel("[ Appointment Schedule ]");
		lblAppointments.setBounds(10, 11, 385, 39);
		lblAppointments.setFont(new Font("Tahoma", Font.PLAIN, 32));
		apptsPanel.add(lblAppointments);
		
		table_Appointments = new JTable();
		
		table_Appointments.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
			},
			new String[] {
				"Patient Name", "Reason", "Date", "Time"
			}
		));
		
		/* put values into treatmentRecords history table */
		table_Appointments.setValueAt("Test - Name", 3, 0);
		table_Appointments.setValueAt("Test - Reason sssssssssssssssssss", 3, 1);
		table_Appointments.setValueAt("Test - 4/19/2011", 3, 2);
		table_Appointments.setValueAt("Test - 4:36 AM", 3, 3);
		
		
		table_Appointments.getColumnModel().getColumn(0).setPreferredWidth(125);
		table_Appointments.getColumnModel().getColumn(0).setMinWidth(125);
		table_Appointments.getColumnModel().getColumn(0).setMaxWidth(125);
		table_Appointments.getColumnModel().getColumn(1).setPreferredWidth(225);
		table_Appointments.getColumnModel().getColumn(1).setMinWidth(235);
		table_Appointments.getColumnModel().getColumn(1).setMaxWidth(235);
		table_Appointments.getColumnModel().getColumn(2).setPreferredWidth(80);
		table_Appointments.getColumnModel().getColumn(2).setMinWidth(80);
		table_Appointments.getColumnModel().getColumn(2).setMaxWidth(80);
		table_Appointments.getColumnModel().getColumn(3).setPreferredWidth(80);
		table_Appointments.getColumnModel().getColumn(3).setMinWidth(80);
		table_Appointments.getColumnModel().getColumn(3).setMaxWidth(80);
		table_Appointments.setBounds(10, 133, 520, 320);
		apptsPanel.add(table_Appointments);
		
		JLabel lblPatientName = new JLabel("Patient Name");
		lblPatientName.setHorizontalAlignment(SwingConstants.LEFT);
		lblPatientName.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPatientName.setBounds(35, 118, 85, 14);
		apptsPanel.add(lblPatientName);
		
		JLabel lblReason_1 = new JLabel("Reason");
		lblReason_1.setHorizontalAlignment(SwingConstants.LEFT);
		lblReason_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblReason_1.setBounds(171, 118, 85, 14);
		apptsPanel.add(lblReason_1);
		
		JLabel lblDate_1 = new JLabel("Date");
		lblDate_1.setHorizontalAlignment(SwingConstants.LEFT);
		lblDate_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblDate_1.setBounds(365, 118, 41, 14);
		apptsPanel.add(lblDate_1);
		
		JLabel gfxAppointments = new JLabel("");
		gfxAppointments.setIcon(new ImageIcon(Window.class.getResource("/gfx/appointment-128.png")));
		gfxAppointments.setBounds(402, 11, 128, 128);
		apptsPanel.add(gfxAppointments);
		
		JLabel lblTime_1 = new JLabel("Time");
		lblTime_1.setHorizontalAlignment(SwingConstants.LEFT);
		lblTime_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblTime_1.setBounds(463, 118, 41, 14);
		apptsPanel.add(lblTime_1);
		
		adminPanel = new JPanel();
		adminPanel.setLayout(null);
		adminPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(adminPanel);
		
		JLabel gfxAdmin = new JLabel("");
		gfxAdmin.setIcon(new ImageIcon(Window.class.getResource("/gfx/Admin-128.png")));
		gfxAdmin.setBounds(385, 28, 128, 128);
		adminPanel.add(gfxAdmin);
		
		JLabel lblAdmin_AddUser = new JLabel("Add User");
		lblAdmin_AddUser.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblAdmin_AddUser.setHorizontalAlignment(SwingConstants.CENTER);
		lblAdmin_AddUser.setBounds(90, 333, 80, 14);
		adminPanel.add(lblAdmin_AddUser);
		
		JLabel lblAdminPanel = new JLabel("[ Admin Panel ]");
		lblAdminPanel.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblAdminPanel.setBounds(10, 11, 340, 67);
		adminPanel.add(lblAdminPanel);
		
		JButton btnAdmin_NewUser = new JButton("");
		btnAdmin_NewUser.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				newUserPanel.setVisible(true);
			}
		});
		btnAdmin_NewUser.setIcon(new ImageIcon(Window.class.getResource("/gfx/User-add-48.png")));
		btnAdmin_NewUser.setBounds(90, 253, 80, 80);
		adminPanel.add(btnAdmin_NewUser);
		
		JButton btnAdmin_ViewTreatmentRecord = new JButton("");
		btnAdmin_ViewTreatmentRecord.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				newTreatmentPanel.setVisible(true);
			}
		});
		btnAdmin_ViewTreatmentRecord.setIcon(new ImageIcon(Window.class.getResource("/gfx/Report-48.png")));
		btnAdmin_ViewTreatmentRecord.setBounds(180, 253, 80, 80);
		adminPanel.add(btnAdmin_ViewTreatmentRecord);
		
		JButton btnAdmin_Search = new JButton("");
		btnAdmin_Search.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				searchPanel.setVisible(true);
			}
		});
		btnAdmin_Search.setIcon(new ImageIcon(Window.class.getResource("/gfx/Search-database-48.png")));
		btnAdmin_Search.setBounds(270, 253, 80, 80);
		adminPanel.add(btnAdmin_Search);
		
		JButton btnAdmin_ViewAppointments = new JButton("");
		btnAdmin_ViewAppointments.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				apptsPanel.setVisible(true);
			}
		});
		btnAdmin_ViewAppointments.setIcon(new ImageIcon(Window.class.getResource("/gfx/Calendar-48.png")));
		btnAdmin_ViewAppointments.setBounds(360, 253, 80, 80);
		adminPanel.add(btnAdmin_ViewAppointments);
		
		JLabel lblAdmin_Records = new JLabel("Records");
		lblAdmin_Records.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblAdmin_Records.setHorizontalAlignment(SwingConstants.CENTER);
		lblAdmin_Records.setBounds(180, 333, 80, 14);
		adminPanel.add(lblAdmin_Records);
		
		JLabel lblAdmin_LookUpUser = new JLabel("Look Up User");
		lblAdmin_LookUpUser.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblAdmin_LookUpUser.setHorizontalAlignment(SwingConstants.CENTER);
		lblAdmin_LookUpUser.setBounds(270, 333, 80, 14);
		adminPanel.add(lblAdmin_LookUpUser);
		
		JLabel lblAdmin_Appointments = new JLabel("Appointments");
		lblAdmin_Appointments.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblAdmin_Appointments.setHorizontalAlignment(SwingConstants.CENTER);
		lblAdmin_Appointments.setBounds(360, 333, 80, 14);
		adminPanel.add(lblAdmin_Appointments);
		
		searchPanel = new JPanel();
		searchPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(searchPanel);
		searchPanel.setLayout(null);
		
		txtSearch_Query = new JTextField();
		txtSearch_Query.setHorizontalAlignment(SwingConstants.CENTER);
		txtSearch_Query.setBounds(138, 308, 203, 46);
		searchPanel.add(txtSearch_Query);
		txtSearch_Query.setColumns(10);
		
		JLabel btnSearch_Submit = new JLabel("");
		btnSearch_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				if (rdbtnFN.isSelected()) {
					
				}
				
				if (rdbtnID.isSelected()) {
					
				}
				
				if (rdbtnFN.isSelected()) {
					
				}
				
			}
		});
		btnSearch_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnSearch_Submit.setBounds(272, 365, 52, 23);
		searchPanel.add(btnSearch_Submit);
		
		JLabel lblSearchUsers = new JLabel("[ Search Users ]");
		lblSearchUsers.setFont(new Font("Tahoma", Font.PLAIN, 33));
		lblSearchUsers.setBounds(10, 11, 445, 72);
		searchPanel.add(lblSearchUsers);
		
		JComboBox comboSearch_UserType = new JComboBox();
		comboSearch_UserType.setFont(new Font("Tahoma", Font.PLAIN, 16));
		comboSearch_UserType.setModel(new DefaultComboBoxModel(new String[] {"Admin", "Doctor", "Nurse", "Patient"}));
		comboSearch_UserType.setBounds(185, 170, 79, 20);
		searchPanel.add(comboSearch_UserType);
		
		JLabel lblSearch_UserType = new JLabel("Search Category:");
		lblSearch_UserType.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblSearch_UserType.setBounds(46, 169, 129, 20);
		searchPanel.add(lblSearch_UserType);
		
		JLabel btnSearch_Clear = new JLabel("");
		btnSearch_Clear.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				txtSearch_Query.setText(null);
			}
		});
		btnSearch_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnSearch_Clear.setBounds(149, 365, 52, 23);
		searchPanel.add(btnSearch_Clear);
		
		JLabel gfxSearch = new JLabel("");
		gfxSearch.setIcon(new ImageIcon(Window.class.getResource("/gfx/Search-256.png")));
		gfxSearch.setBounds(274, 11, 256, 257);
		searchPanel.add(gfxSearch);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setFont(new Font("Tahoma", Font.PLAIN, 16));
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Full Name", "Username", "ID"}));
		comboBox.setBounds(156, 201, 108, 20);
		searchPanel.add(comboBox);
		
		
		JLabel lblSearchBy = new JLabel("Search by:");
		lblSearchBy.setFont(new Font("Tahoma", Font.BOLD, 16));
		lblSearchBy.setBounds(65, 201, 81, 20);
		searchPanel.add(lblSearchBy);
		
		newApptPanel = new JPanel();
		newApptPanel.setLayout(null);
		newApptPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(newApptPanel);
		
		txtName = new JTextField();
		txtName.setColumns(10);
		txtName.setBounds(150, 144, 183, 20);
		newApptPanel.add(txtName);
		
		JLabel lblName = new JLabel("Name:");
		lblName.setHorizontalAlignment(SwingConstants.RIGHT);
		lblName.setBounds(76, 147, 64, 14);
		newApptPanel.add(lblName);
		
		JLabel lblFillOut = new JLabel("Fill out the required fields below:");
		lblFillOut.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblFillOut.setBounds(10, 111, 311, 22);
		newApptPanel.add(lblFillOut);
		
		JLabel lblDoctor = new JLabel("Doctor:");
		lblDoctor.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDoctor.setBounds(77, 168, 64, 14);
		newApptPanel.add(lblDoctor);
		
		JLabel lblReason = new JLabel("Reason:");
		lblReason.setHorizontalAlignment(SwingConstants.RIGHT);
		lblReason.setBounds(20, 211, 120, 22);
		newApptPanel.add(lblReason);
		
		txtReason = new JTextField();
		txtReason.setHorizontalAlignment(SwingConstants.CENTER);
		txtReason.setColumns(10);
		txtReason.setBounds(150, 210, 183, 135);
		newApptPanel.add(txtReason);
		
		
		
		
		JButton btnAppt_Clear = new JButton("");
		btnAppt_Clear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnAppt_Clear.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				
			}
		});
		btnAppt_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnAppt_Clear.setBounds(160, 356, 52, 23);
		newApptPanel.add(btnAppt_Clear);
		
		txtDesiredDate = new JTextField();
		txtDesiredDate.setColumns(10);
		txtDesiredDate.setBounds(275, 188, 58, 20);
		newApptPanel.add(txtDesiredDate);
		
		JLabel lblDate = new JLabel("Date:");
		lblDate.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDate.setBounds(20, 191, 120, 14);
		newApptPanel.add(lblDate);
		
		JLabel lblCreateNewAppointment = new JLabel("[ Create New Appointment ]");
		lblCreateNewAppointment.setFont(new Font("Tahoma", Font.PLAIN, 33));
		lblCreateNewAppointment.setBounds(10, 11, 445, 72);
		newApptPanel.add(lblCreateNewAppointment);
		
		JLabel gfxCalendar = new JLabel("");
		gfxCalendar.setIcon(new ImageIcon(Window.class.getResource("/gfx/Calendar-256.png")));
		gfxCalendar.setBounds(288, 113, 266, 270);
		newApptPanel.add(gfxCalendar);
		
		final JComboBox combo_Doctor = new JComboBox();
		combo_Doctor.setModel(new DefaultComboBoxModel(new String[] {"doctors.getAll()"}));
		combo_Doctor.setBounds(150, 166, 183, 20);
		newApptPanel.add(combo_Doctor);
		
		final JComboBox comboBox_ApptMonth = new JComboBox();
		comboBox_ApptMonth.setModel(new DefaultComboBoxModel(new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}));
		comboBox_ApptMonth.setBounds(150, 188, 123, 20);
		newApptPanel.add(comboBox_ApptMonth);
		
		
		JButton btnAppt_Submit = new JButton("");
		btnAppt_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Map<String, String> addApptSubmit=new HashMap<String, String>();
				addApptSubmit.put("name", txtName.getText());
				addApptSubmit.put("Doctor", (String)combo_Doctor.getSelectedItem());
				addApptSubmit.put("Month", (String)comboBox_ApptMonth.getSelectedItem());
				addApptSubmit.put("Date", txtDesiredDate.getText());
				addApptSubmit.put("Reason", txtReason.getText());
				
				
				
				
			}
		});
		btnAppt_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnAppt_Submit.setBounds(269, 356, 52, 23);
		newApptPanel.add(btnAppt_Submit);
		
		invoicePanel = new JPanel();
		invoicePanel.setBounds(0, 25, 540, 583);
		layeredPane.add(invoicePanel);
		invoicePanel.setLayout(null);
		
		JLabel lblPatientInvoice = new JLabel("[ Patient Invoice ]");
		lblPatientInvoice.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblPatientInvoice.setBounds(10, 11, 371, 58);
		invoicePanel.add(lblPatientInvoice);
		
		tblInvoice = new JTable();
		tblInvoice.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
		tblInvoice.setModel(new DefaultTableModel(
			new Object[][] {
				{"", "", "", ""},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
				{null, null, null, null},
			},
			new String[] {
				"Service", "Unit Price", "Amount", "Total Price"
			}
		));
		tblInvoice.getColumnModel().getColumn(2).setPreferredWidth(30);
		tblInvoice.setBounds(32, 144, 472, 240);
		invoicePanel.add(tblInvoice);
		
		JLabel lblServiceproduct = new JLabel("Service/Product");
		lblServiceproduct.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblServiceproduct.setHorizontalAlignment(SwingConstants.CENTER);
		lblServiceproduct.setBounds(32, 129, 129, 14);
		invoicePanel.add(lblServiceproduct);
		
		JLabel lblUnitCost = new JLabel("Unit Cost");
		lblUnitCost.setHorizontalAlignment(SwingConstants.CENTER);
		lblUnitCost.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblUnitCost.setBounds(159, 129, 129, 14);
		invoicePanel.add(lblUnitCost);
		
		JLabel lblQuantity = new JLabel("Quantity");
		lblQuantity.setHorizontalAlignment(SwingConstants.CENTER);
		lblQuantity.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblQuantity.setBounds(288, 129, 87, 14);
		invoicePanel.add(lblQuantity);
		
		JLabel lblTotalPrice = new JLabel("Total Price");
		lblTotalPrice.setHorizontalAlignment(SwingConstants.CENTER);
		lblTotalPrice.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblTotalPrice.setBounds(374, 129, 130, 14);
		invoicePanel.add(lblTotalPrice);
		
		JLabel gfxCreditCards = new JLabel("");
		gfxCreditCards.setIcon(new ImageIcon(Window.class.getResource("/gfx/Credit_Card_256.png")));
		gfxCreditCards.setBounds(278, 23, 256, 256);
		invoicePanel.add(gfxCreditCards);
		
		nursePanel = new JPanel();
		nursePanel.setBounds(0, 25, 540, 583);
		layeredPane.add(nursePanel);
		nursePanel.setLayout(null);
		
		JLabel gfxNurse = new JLabel("");
		gfxNurse.setIcon(new ImageIcon(Window.class.getResource("/gfx/Nurse-128.png")));
		gfxNurse.setBounds(402, 28, 128, 128);
		nursePanel.add(gfxNurse);
		
		JLabel lblNurse_TreatmentRecords = new JLabel("Treatment Records");
		lblNurse_TreatmentRecords.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNurse_TreatmentRecords.setHorizontalAlignment(SwingConstants.CENTER);
		lblNurse_TreatmentRecords.setBounds(180, 333, 80, 14);
		nursePanel.add(lblNurse_TreatmentRecords);
		
		JLabel lblNursePanel = new JLabel("[ Nurse Panel ]");
		lblNursePanel.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblNursePanel.setBounds(10, 11, 350, 69);
		nursePanel.add(lblNursePanel);
		
		JButton btnNurse_NewPatient = new JButton("");
		btnNurse_NewPatient.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				hideAll();
				newUserPanel.setVisible(true);
			}
		});
		btnNurse_NewPatient.setIcon(new ImageIcon(Window.class.getResource("/gfx/User-add-48.png")));
		btnNurse_NewPatient.setBounds(90, 253, 80, 80);
		nursePanel.add(btnNurse_NewPatient);
		
		JButton btnNurse_NewTreatmentRecord = new JButton("");
		btnNurse_NewTreatmentRecord.addMouseListener(new MouseAdapter() {
			@Override
			/* Nurse - TreatmentRecords */
			public void mouseClicked(MouseEvent e) {
				hideAll();
				newTreatmentPanel.setVisible(true);
			}
		});
		btnNurse_NewTreatmentRecord.setIcon(new ImageIcon(Window.class.getResource("/gfx/Report-48.png")));
		btnNurse_NewTreatmentRecord.setBounds(180, 253, 80, 80);
		nursePanel.add(btnNurse_NewTreatmentRecord);
		
		JButton btnNurse_Search = new JButton("");
		btnNurse_Search.addMouseListener(new MouseAdapter() {
			/* Nurse - Look Up Patient */
			@Override
			public void mouseClicked(MouseEvent e) {
				hideAll();
				searchPanel.setVisible(true);
			}
		});
		btnNurse_Search.setIcon(new ImageIcon(Window.class.getResource("/gfx/Search-database-48.png")));
		btnNurse_Search.setBounds(270, 253, 80, 80);
		nursePanel.add(btnNurse_Search);
		
		JButton btnNurse_ViewAppointments = new JButton("");
		btnNurse_ViewAppointments.addMouseListener(new MouseAdapter() {
			/* Nurse - Appointments */
			@Override
			public void mouseClicked(MouseEvent e) {
				hideAll();
				newApptPanel.setVisible(true);
			}
		});
		btnNurse_ViewAppointments.setIcon(new ImageIcon(Window.class.getResource("/gfx/Calendar-48.png")));
		btnNurse_ViewAppointments.setBounds(360, 253, 80, 80);
		nursePanel.add(btnNurse_ViewAppointments);
		
		lblNurse_AddPatient = new JLabel("Add Patient");
		lblNurse_AddPatient.setHorizontalAlignment(SwingConstants.CENTER);
		lblNurse_AddPatient.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNurse_AddPatient.setBounds(90, 333, 80, 14);
		nursePanel.add(lblNurse_AddPatient);
		
		JLabel lblNurse_LookUpPatient = new JLabel("Look Up Patient");
		lblNurse_LookUpPatient.setHorizontalAlignment(SwingConstants.CENTER);
		lblNurse_LookUpPatient.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNurse_LookUpPatient.setBounds(270, 333, 80, 14);
		nursePanel.add(lblNurse_LookUpPatient);
		
		JLabel lblNurse_Appointments = new JLabel("View Appointments");
		lblNurse_Appointments.setHorizontalAlignment(SwingConstants.CENTER);
		lblNurse_Appointments.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNurse_Appointments.setBounds(356, 333, 90, 14);
		nursePanel.add(lblNurse_Appointments);
		
		patientPanel = new JPanel();
		patientPanel.setLayout(null);
		patientPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(patientPanel);
		
		JLabel gfxUsers = new JLabel("");
		gfxUsers.setIcon(new ImageIcon(Window.class.getResource("/gfx/User-group-128.png")));
		gfxUsers.setBounds(402, 28, 128, 128);
		patientPanel.add(gfxUsers);
		
		JLabel lblPatientPanel = new JLabel("[ Patient Panel ]");
		lblPatientPanel.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblPatientPanel.setBounds(10, 11, 361, 67);
		patientPanel.add(lblPatientPanel);
		
		JButton btnPatient_RequestAppointment = new JButton("");
		btnPatient_RequestAppointment.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				newApptPanel.setVisible(true);
			}
		});
		btnPatient_RequestAppointment.setIcon(new ImageIcon(Window.class.getResource("/gfx/Calendar-48(2).png")));
		btnPatient_RequestAppointment.setBounds(123, 258, 80, 80);
		patientPanel.add(btnPatient_RequestAppointment);
		
		JButton btnPatient_Invoices = new JButton("");
		btnPatient_Invoices.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				invoicePanel.setVisible(true);
				
			}
		});
		btnPatient_Invoices.setIcon(new ImageIcon(Window.class.getResource("/gfx/Invoice-48.png")));
		btnPatient_Invoices.setBounds(213, 258, 80, 80);
		patientPanel.add(btnPatient_Invoices);
		
		JLabel lblNewAppointment = new JLabel("New Appointment");
		lblNewAppointment.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewAppointment.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblNewAppointment.setBounds(123, 337, 80, 25);
		patientPanel.add(lblNewAppointment);
		
		JLabel lblViewInvoices = new JLabel("View Invoices");
		lblViewInvoices.setHorizontalAlignment(SwingConstants.CENTER);
		lblViewInvoices.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblViewInvoices.setBounds(213, 337, 80, 25);
		patientPanel.add(lblViewInvoices);
		
		JButton btnPatient_History = new JButton("");
		btnPatient_History.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();    
				historyPanel.setVisible(true);   
				int row = 0;   
				if(loggedUserType == 'p') {    
					List<TreatmentRecord> tr = loggedUser.getAll(TreatmentRecord.class);  
					List<Symptom> s = null;
					String symptoms = "";
					TreatmentRecord t = null;
					Iterator<TreatmentRecord> i = tr.iterator();
					Iterator<Symptom> is = null;
					while(i.hasNext()) {
						t = i.next();
						s = t.getAll(Symptom.class); 
						is = s.iterator(); 
						while(is.hasNext()) {
							symptoms += (is.next()).getString("symptom"); 
							}   
						table.getModel().setValueAt(symptoms, row, 0);
						table.getModel().setValueAt(t.getDate("date"), row, 1);
						symptoms = "";      
						row++;   
						}   
					} 
				} 
		});
		
		btnPatient_History.setIcon(new ImageIcon(Window.class.getResource("/gfx/Order-history-48.png")));
		btnPatient_History.setBounds(303, 258, 80, 80);
		patientPanel.add(btnPatient_History);
		
		JLabel lblTreatmentHistory = new JLabel("Treatment History");
		lblTreatmentHistory.setHorizontalAlignment(SwingConstants.CENTER);
		lblTreatmentHistory.setFont(new Font("Tahoma", Font.PLAIN, 9));
		lblTreatmentHistory.setBounds(303, 337, 80, 25);
		patientPanel.add(lblTreatmentHistory);
		
		docOrdersPanel = new JPanel();
		docOrdersPanel.setLayout(null);
		docOrdersPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(docOrdersPanel);
		
		txtOrderPatientName = new JTextField();
		txtOrderPatientName.setColumns(10);
		txtOrderPatientName.setBounds(150, 144, 183, 20);
		docOrdersPanel.add(txtOrderPatientName);
		
		JLabel lblOrdersPatientName = new JLabel("Patient Name:");
		lblOrdersPatientName.setHorizontalAlignment(SwingConstants.RIGHT);
		lblOrdersPatientName.setBounds(59, 147, 81, 14);
		docOrdersPanel.add(lblOrdersPatientName);
		
		JLabel label_2 = new JLabel("Fill out the required fields below:");
		label_2.setFont(new Font("Tahoma", Font.BOLD, 14));
		label_2.setBounds(10, 111, 311, 22);
		docOrdersPanel.add(label_2);
		
		JLabel lblOrderNotes = new JLabel("Notes:");
		lblOrderNotes.setHorizontalAlignment(SwingConstants.RIGHT);
		lblOrderNotes.setBounds(20, 189, 120, 22);
		docOrdersPanel.add(lblOrderNotes);
		
		txtOrderNotes = new JTextField();
		txtOrderNotes.setHorizontalAlignment(SwingConstants.CENTER);
		txtOrderNotes.setColumns(10);
		txtOrderNotes.setBounds(150, 188, 183, 135);
		docOrdersPanel.add(txtOrderNotes);
		
		
		
		JButton btnDocOrders_Clear = new JButton("");
		btnDocOrders_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnDocOrders_Clear.setBounds(160, 335, 52, 23);
		docOrdersPanel.add(btnDocOrders_Clear);
		
		txtOrderDate = new JTextField();
		txtOrderDate.setColumns(10);
		txtOrderDate.setBounds(275, 166, 58, 20);
		docOrdersPanel.add(txtOrderDate);
		
		JLabel lblOrderDate = new JLabel("Date:");
		lblOrderDate.setHorizontalAlignment(SwingConstants.RIGHT);
		lblOrderDate.setBounds(20, 169, 120, 14);
		docOrdersPanel.add(lblOrderDate);
		
		JLabel lblAddDoctor = new JLabel("[ Add Doctor Orders ]");
		lblAddDoctor.setFont(new Font("Tahoma", Font.PLAIN, 33));
		lblAddDoctor.setBounds(10, 11, 445, 72);
		docOrdersPanel.add(lblAddDoctor);
		
		JLabel gfxDocOrders = new JLabel("");
		gfxDocOrders.setHorizontalAlignment(SwingConstants.CENTER);
		gfxDocOrders.setIcon(new ImageIcon(Window.class.getResource("/gfx/case-128x128.png")));
		gfxDocOrders.setBounds(331, 113, 209, 270);
		docOrdersPanel.add(gfxDocOrders);
		
		final JComboBox comboOrderMonth = new JComboBox();
		comboOrderMonth.setModel(new DefaultComboBoxModel(new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}));
		comboOrderMonth.setBounds(150, 166, 122, 20);
		docOrdersPanel.add(comboOrderMonth);
		
		JButton btnDocOrders_Submit = new JButton("");
		btnDocOrders_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Map<String, String> addDOSubmit=new HashMap<String, String>();
				addDOSubmit.put("name",txtOrderPatientName.getText());
				addDOSubmit.put("Month", (String)comboOrderMonth.getSelectedItem());
				addDOSubmit.put("Date", txtOrderDate.getText());
				addDOSubmit.put("Notes", txtOrderNotes.getText());
				
			}
		});
		btnDocOrders_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnDocOrders_Submit.setBounds(269, 335, 52, 23);
		docOrdersPanel.add(btnDocOrders_Submit);
		
		chartPanel = new JPanel();
		chartPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(chartPanel);
		
		newTreatmentPanel = new JPanel();
		newTreatmentPanel.setBounds(0, 25, 540, 583);
		layeredPane.add(newTreatmentPanel);
		newTreatmentPanel.setLayout(null);
		
		txtTreatingDoctor = new JTextField();
		txtTreatingDoctor.setBounds(194, 27, 183, 20);
		newTreatmentPanel.add(txtTreatingDoctor);
		txtTreatingDoctor.setColumns(10);
		
		JLabel lblTreatingDoctor = new JLabel("Treating Doctor:");
		lblTreatingDoctor.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTreatingDoctor.setBounds(89, 30, 95, 14);
		newTreatmentPanel.add(lblTreatingDoctor);
		
		JLabel lblTreatmentInformation = new JLabel("Treatment Information:");
		lblTreatmentInformation.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblTreatmentInformation.setBounds(10, 11, 316, 14);
		newTreatmentPanel.add(lblTreatmentInformation);
		
		txtTreatmentDate = new JTextField();
		txtTreatmentDate.setColumns(10);
		txtTreatmentDate.setBounds(194, 100, 183, 20);
		newTreatmentPanel.add(txtTreatmentDate);
		
		JLabel lblTreatmentDate = new JLabel("Date:");
		lblTreatmentDate.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTreatmentDate.setBounds(120, 103, 64, 14);
		newTreatmentPanel.add(lblTreatmentDate);
		
		JLabel lblSymptoms = new JLabel("Symptoms:");
		lblSymptoms.setHorizontalAlignment(SwingConstants.RIGHT);
		lblSymptoms.setBounds(120, 55, 64, 14);
		newTreatmentPanel.add(lblSymptoms);
		
		txtSymptoms = new JTextField();
		txtSymptoms.setHorizontalAlignment(SwingConstants.CENTER);
		txtSymptoms.setColumns(10);
		txtSymptoms.setBounds(194, 49, 183, 49);
		newTreatmentPanel.add(txtSymptoms);
		
		txtTime = new JTextField();
		txtTime.setColumns(10);
		txtTime.setBounds(194, 122, 95, 20);
		newTreatmentPanel.add(txtTime);
		
		JLabel lblTime = new JLabel("Time:");
		lblTime.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTime.setBounds(120, 125, 64, 14);
		newTreatmentPanel.add(lblTime);
		
		JLabel lblNurse = new JLabel("Attending Nurse:");
		lblNurse.setHorizontalAlignment(SwingConstants.RIGHT);
		lblNurse.setBounds(89, 147, 95, 14);
		newTreatmentPanel.add(lblNurse);
		
		txtNurse = new JTextField();
		txtNurse.setColumns(10);
		txtNurse.setBounds(194, 144, 183, 20);
		newTreatmentPanel.add(txtNurse);
		
		JLabel lblDoctorsOrders = new JLabel("Doctor's Orders:");
		lblDoctorsOrders.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDoctorsOrders.setBounds(67, 166, 117, 14);
		newTreatmentPanel.add(lblDoctorsOrders);
		
		JLabel lblDiagnosis = new JLabel("Diagnosis:");
		lblDiagnosis.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDiagnosis.setBounds(66, 202, 118, 14);
		newTreatmentPanel.add(lblDiagnosis);
		
		txtDiagnosis = new JTextField();
		txtDiagnosis.setColumns(10);
		txtDiagnosis.setBounds(194, 202, 183, 57);
		newTreatmentPanel.add(txtDiagnosis);
		
		JLabel lblVitals = new JLabel("Vitals Information:");
		lblVitals.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblVitals.setBounds(10, 268, 316, 14);
		newTreatmentPanel.add(lblVitals);
		
		txtTemperature = new JTextField();
		txtTemperature.setColumns(10);
		txtTemperature.setBounds(194, 333, 183, 20);
		newTreatmentPanel.add(txtTemperature);
		
		JLabel lblBloodPressure = new JLabel("Blood Pressure:");
		lblBloodPressure.setHorizontalAlignment(SwingConstants.RIGHT);
		lblBloodPressure.setBounds(89, 290, 95, 14);
		newTreatmentPanel.add(lblBloodPressure);
		
		JLabel lblPulse = new JLabel("Pulse:");
		lblPulse.setHorizontalAlignment(SwingConstants.RIGHT);
		lblPulse.setBounds(120, 312, 64, 14);
		newTreatmentPanel.add(lblPulse);
		
		txtPulse = new JTextField();
		txtPulse.setColumns(10);
		txtPulse.setBounds(194, 309, 95, 20);
		newTreatmentPanel.add(txtPulse);
		
		txtBloodPressure = new JTextField();
		txtBloodPressure.setColumns(10);
		txtBloodPressure.setBounds(194, 287, 183, 20);
		newTreatmentPanel.add(txtBloodPressure);
		
		JLabel lblTemperature = new JLabel("Temperature:");
		lblTemperature.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTemperature.setBounds(89, 336, 95, 14);
		newTreatmentPanel.add(lblTemperature);
		
		txtHeight = new JTextField();
		txtHeight.setColumns(10);
		txtHeight.setBounds(194, 355, 183, 20);
		newTreatmentPanel.add(txtHeight);
		
		JLabel lblHeight = new JLabel("Height:");
		lblHeight.setHorizontalAlignment(SwingConstants.RIGHT);
		lblHeight.setBounds(90, 359, 95, 14);
		newTreatmentPanel.add(lblHeight);
		
		JLabel lblWeight = new JLabel("Weight:");
		lblWeight.setHorizontalAlignment(SwingConstants.RIGHT);
		lblWeight.setBounds(89, 382, 95, 14);
		newTreatmentPanel.add(lblWeight);
		
		txtWeight = new JTextField();
		txtWeight.setColumns(10);
		txtWeight.setBounds(194, 379, 183, 20);
		newTreatmentPanel.add(txtWeight);
		
		JLabel gfxHeart = new JLabel("");
		gfxHeart.setIcon(new ImageIcon(Window.class.getResource("/gfx/heart-128x128.png")));
		gfxHeart.setBounds(393, 295, 128, 126);
		newTreatmentPanel.add(gfxHeart);
		
		JLabel gfxPills = new JLabel("");
		gfxPills.setIcon(new ImageIcon(Window.class.getResource("/gfx/pills-3-128x128.png")));
		gfxPills.setBounds(393, 82, 128, 126);
		newTreatmentPanel.add(gfxPills);
		
		JLabel btnTreatment_Clear = new JLabel("");
		btnTreatment_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnTreatment_Clear.setBounds(209, 410, 51, 26);
		newTreatmentPanel.add(btnTreatment_Clear);
		
		JLabel btnTreatment_Submit = new JLabel("");
		btnTreatment_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				//
			}
		});
		btnTreatment_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnTreatment_Submit.setBounds(310, 410, 51, 26);
		newTreatmentPanel.add(btnTreatment_Submit);
		
		JButton btnAdd = new JButton("Add");
		btnAdd.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				// bring docOrdersPanel
				
			}
		});
		btnAdd.setBounds(193, 167, 89, 23);
		newTreatmentPanel.add(btnAdd);
		
		menu = new JMenuBar();
		menu.setEnabled(false);
		menu.setBounds(0, 0, 540, 25);
		layeredPane.add(menu);
		
		// MENU - Back Button 
		JButton btnHome = new JButton("Home");
		btnHome.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				switch(loggedUserType) {
					case 'a':
						adminPanel.setVisible(true);
						break;
					case 'n':
						nursePanel.setVisible(true);
						break;
					case 'd':
						docPanel.setVisible(true);
						break;
					case 'p':
						patientPanel.setVisible(true);
						break;
				}
			}
		});
		menu.add(btnHome);
		
		Component menu_strut1 = Box.createHorizontalStrut(36);
		menu.add(menu_strut1);
		
		/* Menu - LoggedUser */
		JLabel lblLoggedUser = new JLabel();

		System.out.println(loggedUser);
		
		/* display LoggedUser Type */
		if (loggedUser != null && loggedUser.equals("p")){
			lblLoggedUser.setText("Logged in as: --------------");
		} else if ('p' == 'n') {
			lblLoggedUser.setText("Logged in ");
		} else if ('p' == 'd') {
			lblLoggedUser.setText("Logged in ");
		} else if ('p' == 'a') {
			lblLoggedUser.setText("Logged in ");
		} else lblLoggedUser.setText("Logged in ");

		menu.add(lblLoggedUser);
		
		Component menu_strut2 = Box.createHorizontalStrut(10);
		menu.add(menu_strut2);
		
		btnMenuLogout = new JButton("Log Out");
		btnMenuLogout.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				hideAll();
				Base.close();
				loggedUser = null;
				menu.setVisible(false);
				loginPanel.setVisible(true);
				btnMenuLogout.setEnabled(false);
			}
		});
		
		Component menu_strut3 = Box.createHorizontalStrut(260);
		menu.add(menu_strut3);
		menu.add(btnMenuLogout);
		menu.setVisible(false);
		
		loginPanel = new JPanel();
		loginPanel.setBounds(0, 0, 540, 608);
		layeredPane.add(loginPanel);
		loginPanel.setLayout(null);
		
		
		txtField_Username = new JTextField();
		txtField_Username.setText(null);
		txtField_Username.setBounds(169, 271, 201, 20);
		loginPanel.add(txtField_Username);
		txtField_Username.setColumns(10);
		
		txtField_Password = new JTextField();
		txtField_Password.setText(null);
		txtField_Password.setColumns(10);
		txtField_Password.setBounds(169, 302, 201, 20);
		loginPanel.add(txtField_Password);
		
		JLabel lblLogin = new JLabel("Login:");
		lblLogin.setHorizontalAlignment(SwingConstants.RIGHT);
		lblLogin.setBounds(113, 274, 46, 14);
		loginPanel.add(lblLogin);
		
		JLabel lblPassword = new JLabel("Password:");
		lblPassword.setHorizontalAlignment(SwingConstants.RIGHT);
		lblPassword.setBounds(91, 305, 68, 14);
		loginPanel.add(lblPassword);
		
		// LOGINPANEL - Clear Button Code
		JButton btnLogin_Clear = new JButton("");
		btnLogin_Clear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// Should erase values?
				txtField_Username.setText(null);
				txtField_Password.setText(null);
				
			}
		});
		btnLogin_Clear.setIcon(new ImageIcon(Window.class.getResource("/gfx/clear.png")));
		btnLogin_Clear.setBounds(179, 333, 52, 23);
		loginPanel.add(btnLogin_Clear);
		
		// LOGINPANEL - Submit
		JButton btnLogin_Submit = new JButton("");
		btnLogin_Submit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
					Base.open("com.mysql.jdbc.Driver",
						"jdbc:mysql://chromiumblue.net/2340", "teamteamwork",
						"YDmNT8umyYBemwfn");
				
				hideAll();

				System.out.println(txtField_Username.getText());
				
				/* testing with username login */
				loginPanel.setVisible(false);
				
				if(!txtField_Username.getText().equals("") && !txtField_Password.getText().equals("")) {
					Object[] login = LoginController.checkLogin(txtField_Username.getText(), txtField_Password.getText());
					char type = (Character)login[0];
					if(login[1] != null) {
						switch(type) {
							case 'a':
								loggedUserType = 'a';
								adminPanel.setVisible(true);
								break;
							case 'p':
								loggedUserType = 'p';
								patientPanel.setVisible(true);
								break;
							case 'n':
								loggedUserType = 'n';
								nursePanel.setVisible(true);
								break;
							case 'd':
								loggedUserType = 'd';
								docPanel.setVisible(true);
								break;
						}
						loggedUser = (Model)login[1];
					}
				}
				menu.setVisible(true);
			}
		});
		btnLogin_Submit.setIcon(new ImageIcon(Window.class.getResource("/gfx/submit.png")));
		btnLogin_Submit.setBounds(313, 333, 52, 23);
		loginPanel.add(btnLogin_Submit);
		
		JLabel gfxHandshake = new JLabel("");
		gfxHandshake.setHorizontalAlignment(SwingConstants.CENTER);
		gfxHandshake.setIcon(new ImageIcon(Window.class.getResource("/gfx/Partnership-256.png")));
		gfxHandshake.setBounds(0, 75, 540, 247);
		loginPanel.add(gfxHandshake);
		
		JLabel lblLoginGraphicHere = new JLabel("[ TeamWork Hospital ]");
		lblLoginGraphicHere.setFont(new Font("Tahoma", Font.PLAIN, 32));
		lblLoginGraphicHere.setHorizontalAlignment(SwingConstants.CENTER);
		lblLoginGraphicHere.setBounds(0, 21, 540, 177);
		loginPanel.add(lblLoginGraphicHere);
	
		hideAll();
		loginPanel.setVisible(true);
	}

	
	public void hideAll() {
		newUserPanel.setVisible(false);
		newApptPanel.setVisible(false);
		docOrdersPanel.setVisible(false);
		userInfo.setVisible(false);
		newTreatmentPanel.setVisible(false);
		invoicePanel.setVisible(false);
		docPanel.setVisible(false);
		adminPanel.setVisible(false);
		nursePanel.setVisible(false);
		patientPanel.setVisible(false);
		chartPanel.setVisible(false);
		loginPanel.setVisible(false);
		searchPanel.setVisible(false);
		historyPanel.setVisible(false);
		apptsPanel.setVisible(false);
	}

	public static void drawChart(DefaultCategoryDataset data) {
		/* create a dataset */
		
		/*DefaultCategoryDataset data = new DefaultCategoryDataset();
//		DefaultKeyedValuesDataset data = new DefaultKeyedValuesDataset();
		//DefaultPieDataset data = new DefaultPieDataset();
		data.addValue(130, "Weight", "July, 2011");
		data.addValue(150, "Weight", "August, 2011");
		data.addValue(135, "Weight", "September, 2011");
		data.addValue(130, "Weight", "October, 2011");
		data.addValue(140, "Weight", "November, 2011");
		data.addValue(145, "Weight", "December, 2011");
		data.addValue(140, "Weight", "January, 2012");
		data.addValue(145, "Weight", "February, 2013");*/
		
		
		/* create a chart */
		JFreeChart chart = ChartFactory.createLineChart(
				"Weight Change Over Appointments",
				"Date",
				"Weight",
				data,
				PlotOrientation.VERTICAL,
				true, true, false);
		
		
		/* create and display a frame */
		ChartFrame frame = new ChartFrame("First", chart);
		frame.pack();
		frame.setVisible(true);
	}
}
